package Day08;

import java.util.Scanner;

/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-09-19
 * Time: 20:13
 * To BE A Better Person-2020-3-2
 */
public class TestDemo {
    public static boolean isLexi(String s1,String s2){
        int i=0;
        for (; i <Math.min(s1.length(),s2.length());  i++) {
            if(s1.charAt(i)>s2.charAt(i)){
                return false;
            }
        }
        return true;
    }
    public static boolean isLen(String s1,String s2){
        if(s2.length()>=s1.length()){
            return true;
        }
        return false;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String[] s=new String[n];
        boolean lexi=true;
        boolean len=true;
        for(int i = 0; i < n; i++){
            s[i]=sc.next();
        }

        for (int i = 0; i < s.length-1; i++) {
            lexi=isLexi(s[i],s[i+1]);
            len=isLen(s[i],s[i+1]);
        }
        if(lexi && len){
            System.out.println("both");
        }else if(lexi){
            System.out.println("lexicographically");
        }else if(len){
            System.out.println("lengths");
        }else{
            System.out.println("none");
        }

    }
}
